/*
 * Copyright (c) 2010 CCX(China) Co.,Ltd. All Rights Reserved.
 *
 * This software is the confidential and proprietary information of
 * CCX(China) Co.,Ltd. ("Confidential Information").
 * It may not be copied or reproduced in any manner without the express 
 * written permission of CCX(China) Co.,Ltd.
 * 
 *	Created on 2010-12-13 下午04:22:53
 */
package cn.com.ccxe.core.entity;

import java.io.Serializable;

import cn.com.ccxe.core.util.CodeUtil;

import com.sleepycat.persist.model.Entity;

/**
 * 文章链接
 * @author hetao
 */
@Entity
public final class ArticleLink extends Link implements Serializable {


	private static final long serialVersionUID = 2614403175233813056L;
	
	private int statusCode;
	private int moduleId;
	private String MD5Value;
	private String title;
	

	public ArticleLink() {
	}
	public ArticleLink(String url) {
		
		setPath(url);
		if(getUpdateTime() == 0) {
			setUpdateTime(UpdateLevel.UPDATE_DEFAULT);
		}
	}

	public boolean md5IsEmpty() {
		return (MD5Value != null) && !("".equals(MD5Value));
	}
	
	@Override
	public int hashCode() {
		int result = 17;
		result = 31 * result + getFetchTime();
		result = 31 * result + statusCode;
		result = 31 * result + moduleId;
		result = 31 * result + CodeUtil.byteArray2Int((this.getPath()).getBytes());
		return result;
	}
	
	@Override
	public boolean equals(Object o) {
		if (this == o) {
			return true;
		}
		if (o instanceof ArticleLink) {
			if (o == null || getClass() != o.getClass()) {
				return false;
			}
			ArticleLink w = (ArticleLink) o;
			return this.getPath().equals(w.getPath()) 
						&& moduleId == w.getModuleId()
						&& getFetchTime() == w.getFetchTime() 
						&& this.getUpdateTime() == w.getUpdateTime();
		}
		return false;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("moduleId:"+moduleId)
			.append(",path:"+getPath())
			.append(",title:"+title)
			.append(",FetchTime:"+getFetchTime())
			.append(",UpdateTime,"+ getUpdateTime());
		return sb.toString();
	}

	/**              GET METHOD             */
	public int getModuleId() { return moduleId;}
	public int getStatusCode() { return statusCode;}
	public String getMD5Value() { return MD5Value;}
	public String getTitle() { return title;}
	
	/**              SET METHOD             */
	public void setModuleId(int moduleId) { this.moduleId = moduleId;}
	public void setStatusCode(int statusCode) {	this.statusCode = statusCode;}
	public void setMD5Value(String mD5Value) { this.MD5Value = mD5Value;}
	public void setTitle(String title) { this.title = title;}


}
